#ifndef PAINTTOOL_H
#define PAINTTOOL_H
#include <QtOpenGL>
#include <QOpenGLWidget>
#include <QOpenGLFunctions_4_5_Core>
#include "paintdata.h"
#include <QFile>

class CPaint2DTexture
{
public:
    CPaint2DTexture();
    virtual ~CPaint2DTexture();
    void createImage(QString& name, QFont &font, QColor& color);
    void createImage(QString& filePath);
    void resizeSize(int w, int h);
    void createTexture();
public:
    QOpenGLTexture* texture;
    QImage* img;
    int width;
    int height;
};

class CPaint2DTextTool
{
public:
    CPaint2DTextTool(int n, bool occlusion = true);
    virtual ~CPaint2DTextTool();
    void initShaderProgram();
    CPaint2DTexture* setText(int index, QString& name, QFont &font, QColor& color);
    CPaint2DTexture* setText(int index, QString& filePath);
    void resizeSize(int index, int w, int h);
    void createTextures();
    CPaint2DTexture* getTexture(int index);
    void getSize(int index, GLdouble* weight, GLdouble* height);
    bool drawTexture(int index, GLdouble wx, GLdouble wy, GLdouble xOffset, GLdouble yOffset);
    bool drawTexture(int index, GLdouble wx, GLdouble wy);
private:
    void draw(CPaint2DTexture* tmp, int wx, int wy);
private:
    int m_nums;
    bool m_occlusion;
    QOpenGLVertexArrayObject VAO;
    QOpenGLBuffer VBO;
    QOpenGLShaderProgram shaderProgram;
    CPaint2DTexture** textures;
};
class CPaint3DTextTool
{
public:
    CPaint3DTextTool();
    virtual ~CPaint3DTextTool();
    /**
     * @brief drawText  绘制三维文字
     * @param start  文字的位置
     * @param color  颜色
     * @param text   文字
     */
    void drawText(Point3d& start, QColor& color, QString& text);
};

class CQTTextTool
{
public:
    CQTTextTool(QPaintDevice * dev);
    virtual ~CQTTextTool();
    /**
     * @brief drawQtText  平面文字 使用Qpainter
     * @param x 开始位置
     * @param y 结束文字
     * @param text
     */
    void drawText(float x, float y, QString text);
private:
    QPainter* m_painter;
};

#endif // PAINTTOOL_H
